<template>
  <div>
    <el-dialog
      :title="formtype == 1 ? '手工排班' : '手工排班'"
      width="460px"
      @close='cancel'
      :visible.sync="dialogFormVisible"
    >
      <el-form :model="form" :rules="rules" ref="ruleForm" label-position="left">
        <el-form-item
          label="部门"
          :label-width="formLabelWidth"
        >
          <el-input
            class="input_border_bottom input_disabled"
            v-model="form.OrganizationName"
            disabled
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          label="职员"
          :label-width="formLabelWidth"
        >
          <el-input
            class="input_border_bottom input_disabled"
            v-model="form.StaffName"
            disabled
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          label="日期"
          :label-width="formLabelWidth"
        >
          <el-input
            class="input_border_bottom input_disabled"
            v-model="form.ShiftDate"
            disabled
            auto-complete="off"
          ></el-input>
        </el-form-item>
  
        <el-form-item
          label="上班时间"
          prop="WorkTime"
          :label-width="formLabelWidth"
        >
          <el-time-select
            placeholder="上班时间"
            v-model="form.WorkTime"
            :clearable="false"
            class="time_select_defin"
            :picker-options="{
              start: '00:00',
              step: '00:01',
              end: '24:00'
            }"
          >
          </el-time-select>
        </el-form-item>
        <el-form-item
          label="下班时间"
          prop="ClosingTime"
          :label-width="formLabelWidth"
        >
          <el-time-select
            placeholder="下班时间"
            v-model="form.ClosingTime"
            :clearable="false"
            class="time_select_defin"
            :picker-options="{
              start: '00:00',
              step: '00:01',
              end: '24:00',
              minTime: form.WorkTime
            }"
          >
          </el-time-select>
        </el-form-item>
        <el-form-item label="描述" prop="Desc" :label-width="formLabelWidth">
          <el-input
            class="textarea_border_bottom"
            v-model="form.Desc"
            type="textarea"
            placeholder="请输入对当前排班的描述"
            auto-complete="off"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="commit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
var that
export default {
  data() {
    return {
      dialogFormVisible: false,
      formtype: 1,
      formLabelWidth: '100px',
      value6: [],
      tableData: [],
      rules: {
          WorkTime: [
            { required: true, message: '请选择上班时间', trigger: 'blur' },
          ],
          ClosingTime: [
            { required: true, message: '请选择下班时间', trigger: 'blur' },
          ],
        },
      form: {
        OrganizationName: '',
        Desc: '',
        ShiftDate: '',
        WorkTime: '',
        StaffId: '',
        StaffName: '',
        StartDate: '',
        EndDate: '',
        ClosingTime: '',
        HandShift: {},
      }
    }
  },
  watch: {
    "$store.state.Humanmanage.SaveStaffShiftHand": function (data) {
      this.$message({
            type: 'success',
            message: '操作成功!'
          });
    this.cancel();
    this.$parent.getlistdata();
    },
  },
  created() {
    that = this;
  },
  methods: {
    commit() {
    this.form.StartDate = this.form.ShiftDate;
    this.form.EndDate = this.form.ShiftDate;
    this.form.HandShift.Date = this.form.ShiftDate;
    this.form.HandShift.WorkTime = this.form.WorkTime;
    this.form.HandShift.ClosingTime = this.form.ClosingTime;
    if (this.form.HandId) {
      this.form.HandShift.Id = this.form.HandId;
    }
      this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            let obj = {
              "MN": "SaveStaffShiftHand",
              "RequestId": 1,
              "UserId": 1,
              "DataContent": this.form
            }
            this.MIX_send(obj);
          } else {
            return false;
          }
        });
    },
    cancel(){
      this.form={
        OrganizationName: '',
        Desc: '',
        ShiftDate: '',
        WorkTime: '',
        StaffId: '',
        StaffName: '',
        StartDate: '',
        EndDate: '',
        ClosingTime: '',
        HandShift: {},
      }
      this.dialogFormVisible = false;
    },
  },
}
</script>

<style lang="less" scoped>
</style>